package com.qs.controller;


import com.qs.annotation.OperationLog;
import com.qs.pojo.vo.OrderExpireVo;
import com.qs.response.Response;
import com.qs.service.IPayInfoService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 订单支付记录表 前端控制器
 * </p>
 *
 * @author author
 * @since 2023-12-08
 */
@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/pay/info")
@RequiredArgsConstructor
public class PayInfoController {

    private final IPayInfoService payInfoService;

    /**
     * 获取当前用户的待付款订单
     * @param userId
     * @return
     */
    @GetMapping("/order/{userId}")
    public Response getWaitPayOrder(@PathVariable("userId") Integer userId){
        log.info("获取当前用户的待付款订单请求进来了--------------");
        List<OrderExpireVo> orderIdList = payInfoService.getWaitPayOrder(userId);
        return Response.success(orderIdList);
    }

    /**
     * 获取订单的创建时间
     * @param orderId
     * @return
     */
    @GetMapping("/order/create/{orderId}")
    public Response getOrderCreateTime(@PathVariable("orderId") String orderId){
        log.info("获取订单的创建时间请求进来了--------------");
        Map<String,Object> timeMap = payInfoService.getOrderCreateTime(orderId);
        return Response.success(timeMap);
    }

    /**
     * 获取当前用户的已付款订单
     * @param userId
     * @return
     */
    @GetMapping("/have/order/{userId}")
    public Response getHavePayOrderData(@PathVariable("userId") Integer userId){
        log.info("获取当前用户的已付款订单请求进来了--------------");
        List<String> orderIdList = payInfoService.getHavePayOrderData(userId);
        return Response.success(orderIdList);
    }

}
